package cn.boy.dao;

import java.io.InputStream;
import java.util.Properties;


public class StudentDaoFactory {
	
	private StudentDao dao;
	private static StudentDaoFactory instance = new StudentDaoFactory();

	private StudentDaoFactory() {

		try {
			Properties prop = new Properties();
			InputStream is = StudentDaoFactory.class.getClassLoader()
					.getResourceAsStream("config.properties");
			prop.load(is);
			String documentDaoClass = prop.getProperty("studentDaoClass");
			Class clazz = Class.forName(documentDaoClass);
			dao = (StudentDao) clazz.newInstance();
		} catch (Exception e) {
			e.printStackTrace();
			throw new ExceptionInInitializerError(e);
		}

	}

	public static StudentDaoFactory getInstance() {
		return instance;
	}

	public StudentDao getStudentDao() {
		return dao;
	}

}
